#ifndef XLCOMM_NET_HTTPREQUEST_H_
#define XLCOMM_NET_HTTPREQUEST_H_

#include <map>
#include <string>

#include "xlcomm/copyable.h"
#include "xlcomm/net/buffer.h"

namespace xlcomm {
namespace net {

class HttpRequest : copyable {
 public:
  enum Method { kInvalid, kGet, kPost, kHead, kPut, kDelete };
  enum Version { kUnknown, kHttp10, kHttp11 };

  HttpRequest() : method_(kInvalid), version_(kUnknown), body_len_(0) {}

  std::string MethodToString() const {
    if (method_ == kGet) return "GET";
    if (method_ == kPost) return "POST";
    if (method_ == kHead) return "HEAD";
    if (method_ == kPut) return "PUT";
    if (method_ == kDelete) return "DELETE";
    return "Invalid";
  }

  std::string GetHeader(const std::string& key) const {
    std::string value;
    std::map<std::string, std::string>::const_iterator it = headers_.find(key);
    if (it != headers_.end()) value = it->second;
    return value;
  }

  Method method_;
  std::string path_;
  std::string query_;
  Version version_;
  std::map<std::string, std::string> headers_;
  std::string body_;
  size_t body_len_;
};

}  // namespace net
}  // namespace xlcomm

#endif  // XLCOMM_NET_HTTPREQUEST_H_